// pages/film/film.js
const app = getApp();
Page({
  data: {
    //电影列表
    list: [],
    //轮播图列表
    SwiperList: []
  },
  onLoad() {
    this.getData();
    this.getSwiperList();
  },
  getData(type) {
    app.get("film/list?type=" + type).then(res => {
      let list = res.data
      list = list.map((item) => {
        let actors = item.actors.filter(item => item.role !== '导演');
        let names = actors.map(item => item.name)
        let namesStr = names.join(',')
        return {
          ...item,
          actorStr: namesStr
        }
      })
      this.setData({
        list: list
      }, () => {
        wx.hideLoading()
      })
    })
  },
  getSwiperList() {
    app.get("film/banners").then((res) => {
      this.setData({
        SwiperList: res.data
      })
    })
  },
  onChange(event) {
    let type = event.detail.name;
    this.getData(type);
  },
  
})